package sketch.specs;

import java.util.List;

import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.Comment;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;

import sketch.ast.ASTUtils;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;


public class MethodDeclarationDumperTest extends TestCase {

	public static Test suite() {
		return new TestSuite(MethodDeclarationDumperTest.class);
	}
	
	public void testDumper() {
//		String filePath = "./tests/sketch/specs/redundantCode.txt";
		String filePath = "testfiles/sketch/specs/RedundantCode.java";
		CompilationUnit unit = ASTUtils.astRoot(filePath);
		List<MethodDeclaration> methods = ASTUtils.getMethodsWithAnnotation(unit, "TestSketch");
		//get the comment list
		List<Comment> cs = unit.getCommentList();
		//unit.getLineNumber(position)
		cs = ASTUtils.blockComments(cs);
		for(MethodDeclaration method : methods) {
			MethodDumperAfterRemovingUnusedVars dumper = new MethodDumperAfterRemovingUnusedVars(method);
			System.out.println(dumper.dumpMethodWithUnusedVarRemoved());
		}
	}
}
